package com.xingxue.logistics.common.utils;

import java.util.Random;

/**
 * @author Kris at 2018/9/30 10:41
 */
public class CommonUtils {

    /**
     * 生成随机字符串
     * @param size 长度
     * @param chars 字符库
     * @return
     */
    public static String createCodeStr(int size,char[] chars){
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for(int i=0,len=chars.length;i<size;i++){
            int r = random.nextInt(len);
            sb.append(chars[r]);
        }
        return sb.toString();
    }
}
